import os
import sys
import re


if __name__ == '__main__':

    f_dict = {}

    for r in sys.stdin:
        # print(r)
        if r.strip() != '':
            host = r.split(':')[0]
            # print(host)
            f_list = r.split(':')[1].strip().split(' ')
            # print(host, f_list)

            for i in range(0, len(f_list) - 1):
                for j in range(1, len(f_list)):
                    # f_dict[(f_list[i], f_list[j])] = host
                    print(f_list[i], f_list[j], host)